<!--
 * @Author: wangshuguang
 * @Date: 2022-02-22 09:47:27
 * @LastEditTime: 2022-03-24 18:12:11
 * @LastEditors: wangshuguang
 * @Description: 流量详单详情
-->
<template>
  <div class="flowDetail">
    <HeaderComp title="消耗记录详情" />
    <div class="title">
      <span class="date">{{ queryData.statisticalTime }}</span>
      <span class="num">{{ queryData.consumeTypeZh }} {{ queryData.allConsume }}</span>
    </div>
    <van-list  
      v-model="loading"
      :finished="finished"
      offset="100"
      finished-text="没有更多了"
      @load="getListData"
    class="dataList">
      <div v-for="item of dataList" :key="item.mobile" class="dataItem">
        <div class="left">
          <div class="dataListTitle">会员：{{item.name}}</div>
          <div class="mobile">手机号:{{item.phone}}</div>
        </div>
        <div class="right">{{item.vipConsume}}</div>
      </div>
    </van-list>
  </div>
</template>

<script>

import { merchAppRptDayDetail } from "@/api/flow/index";
import { mapGetters } from "vuex";
export default {
  data(){
    return {
      loading: false,
      finished: false,
      dataList: [
        { name: "张三", mobile: '15188881234', num: -1 },
        { name: "张三", mobile: '15188881233', num: -2 },
        { name: "张三", mobile: '15188881231', num: -3 },
      ],
      pageObj:{
        pageSize: 10,
        pageNum: 1
      },
    }
  },
  computed:{
    queryData(){
      return this.$route.query
    },
    ...mapGetters(['flowQueryData'])
  },
  mounted(){
    this.dataList = []
    this.getListData()
  },
  methods:{
    getListData(){
      const { merchantId } = this.flowQueryData
      const { consumeType,statisticalTime } = this.$route.query
      let obj = {
        pageNum: this.pageObj.pageNum,
        pageSize: this.pageObj.pageSize,
        merchantId,
        consumeType,
        statisticalTime
      }
      this.loading = true
      merchAppRptDayDetail(obj).then(res => {
        console.log('res',res)
        const { list, total } = res.data.data
        this.dataList.push(...list)
        this.pageObj.pageNum += 1
        this.loading = false
        if(this.dataList.length == total){
          this.finished = true
        }
      })
    }
  }
}
</script>

<style lang="less">
.flowDetail{
  .title{
    background: #F3F3F3;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    padding: 32px;
    font-size: 32px;
    color: #131313;
  }
  .dataList{
    padding: 0 30px;
    .dataItem{
      font-size: 32px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 30px 0;
      border-bottom: 1px solid #E7E7E7;
      .dataListTitle{
        color: #131313;
        margin-bottom: 30px;
      }
      .mobile{
        color: #3D3D3D;
        opacity: 0.8;
      }
    }
  }
}
</style>